#pragma once

#include "../util/Tools.h"
#include "Constants.h"

typedef struct FCB {
    char name[MAX_FILE_NAME_LENGTH];
    short inodeNumber;
} FCB;

static short FCBList_createFCB(FCB FCBList[], char *fileName, short inodePtr) {
    FCB *entry = NULL;
    short i = 0;
    for (; i < FCB_LIST_SIZE; i++) {
        entry = FCBList + i;
        if (entry->name[0] == '\0') {
            break;
        }
    }
    EXIT_IF_NULL(entry, "分配FCB失败，无可用FCB")
    strcpy(entry->name, fileName);
    entry->inodeNumber = inodePtr;
    return i;
}